{include file="public/header"}
<body class="login-bg">
    
    <div class="login">
        <div class="message">千泓后台管理</div>
        <div id="darkbannerwrap"></div>
        
        <form method="post" class="layui-form" >
            <input name="username" placeholder="用户名"  type="text" lay-verify="required" class="layui-input" id="username">
            <hr class="hr15">
            <input name="password" lay-verify="required" placeholder="密码"  type="password" class="layui-input" id="password">
            <hr class="hr15">
            <input value="登录" lay-submit lay-filter="login" style="width:100%;" type="submit" id="loginBtn">
            <hr class="hr20" >
        </form>
    </div>
    {include file="public/base_js"}
    <script>
        $(function  () {
              $('#loginBtn').on('click',function () {
					if (!$('#username').val() || !$('#password').val()) {
						layer.msg('用户名和密码不得为空');
						return;
					}
                    $.ajax({
                        type:'post',
                        url: "{:url('login/check')}",
                        data: $('.layui-form').serialize(),
                        dataType:'json',
                        success:function (data) {
                            if (data.status == 1) {
                                layer.msg(data.msg, {'icon': 1,'time': 500} ,function(){
                                    window.location.href="{:url('index/index')}";
                                });
                            } else {
                                layer.msg(JSON.stringify(data.msg));
                                return false;
                            }
                        }
                    });
                    return false;
              });
        })
    </script>
</body>
</html>